<?php
class Model_Module extends CI_Model 
{
    function __construct()
    {
        parent::__construct();
    }
	
	function get_module_name($module_id)
	{
		$query = $this->db->get_where('user_module', array('module_id' => $module_id), 1);
		
		if ($query->num_rows() ==1)
		{
			$row = $query->row();
			return $this->lang->line($row->module_key);
		}
		
		return $this->lang->line('error_unknown');
	}
	
	function get_module_desc($module_id)
	{
		$query = $this->db->get_where('user_module', array('module_id' => $module_id), 1);
		if ($query->num_rows() ==1)
		{
			$row = $query->row();
			return $this->lang->line($row->module_key_desc);
		}
	
		return $this->lang->line('error_unknown');	
	}
	
	function get_all_module()
	{
		$this->db->from('user_module');
		$this->db->where("status", "0");
		$this->db->order_by("sort_order", "asc");
		return $this->db->get();		
	}
	
	function get_default_module()
	{
		$this->db->from('user_module');
		$this->db->where("status", "1");
		$this->db->order_by("sort_order", "asc");
		return $this->db->get();		
	}
	
	
	
	function get_allowed_module($person_id)
	{
		$this->db->from('user_module');
		$this->db->join('user_permission','user_permission.module_id=user_module.module_id');
		$this->db->where("user_permission.user_id",$person_id);
		$this->db->order_by("sort_order", "asc");
		return $this->db->get();		
	}
}
?>
